package com.seat.row;

import android.app.Application;
import android.util.Log;

import com.seat.row.util.ACache;
import com.seat.row.util.AbLogUtil;
import com.tencent.smtt.sdk.QbSdk;

/**
 * 作者：Hailong.Yang on 2017/8/3.
 * 该类：
 */

public class App extends Application {
    private static App instance;

    public static App getInstance() {
        return instance;
    }

    //显示Log日志
    private boolean isDebugModel = true;

    public boolean getDebugModel() {
        return isDebugModel;
    }


    private ACache aCache;

    /**
     * 返回缓存xml
     *
     * @return
     */
    public ACache getACache() {
        return aCache;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        aCache = ACache.get(instance,getPackageName());

        if (!isDebugModel) {
            AbLogUtil.closeAll();
        }
        setupWeb();
    }


    private void setupWeb() {
        //搜集本地tbs内核信息并上报服务器，服务器返回结果决定使用哪个内核。

        QbSdk.PreInitCallback cb = new QbSdk.PreInitCallback() {

            @Override
            public void onViewInitFinished(boolean arg0) {
                // TODO Auto-generated method stub
                //x5內核初始化完成的回调，为true表示x5内核加载成功，否则表示x5内核加载失败，会自动切换到系统内核。
                Log.d("app", " onViewInitFinished is " + arg0);
            }

            @Override
            public void onCoreInitFinished() {
                // TODO Auto-generated method stub
            }
        };
        //x5内核初始化接口
        QbSdk.initX5Environment(getApplicationContext(), cb);
    }
}
